function EditSampleAttribute(container, item, callbackFunc, options) {
  this._container = container;
  this._item = item;
  this._callbackFunc = callbackFunc;

  this._parent = (options && options.parent) ? options.parent : null;
  this._index = (options && options.index) ? options.index : null;
  
  if (!this._item) {
    this._item = SampleAttribute.instance();
  }
  this._createElements();
}

EditSampleAttribute.prototype._createElements = function() {
  var unique, _self = this;
  
  unique = MiscUtils.unique()
  new EditSampleAtrributeGui(unique, this._container, this._item);
  
  var gui = { attributeName: document.getElementById(unique + 'attributeName'),
              attributeDel: document.getElementById(unique + 'attributeDel'),
              optionNew: document.getElementById(unique + 'option')
            }
            
  gui.attributeName.onchange = function() { _self._item.name = this.value; }
  gui.attributeDel.onclick = function() { _self._parent.attributes.splice(_self._index, 1);
                                          _self._callbackFunc();
                                          return false;
                                        };


  gui.optionNew._item = this._item;
  gui.optionNew._index = this._index;
  gui.optionNew.onclick = function() { _self._item.options[_self._item.options.length] = SampleAttributeOption.instance();
                                       _self._callbackFunc();
                                       return false;
                                     };

  for (var i = 0, il = this._item.options.length; i < il; i++) {
    var option = this._item.options[i];
    var optionName = document.getElementById(unique + i + 'optionName');
    
    optionName._option = option;
    optionName.onchange = function() { this._option.name = this.value; };
    
    var optionDel = document.getElementById(unique + i + 'optionDel');
    optionDel._index = i;
    optionDel.onclick = function() { _self._item.options.splice(this._index, 1);
                                     _self._callbackFunc();
                                     return false;
                                   };
  }
};